<?php

// 会员优惠券记录表

namespace app\console\model;

use think\Model;
use think\Request;

class MemberCoupon extends Model
{

    protected static function init()
    {

        // 写入前
        self::event('before_write', function ($data) {

            if (Request::instance()->param('interval_timer')) {
                $interval_timer = explode(' / ', Request::instance()->param('interval_timer'));
                $data->start_time = strtotime($interval_timer[0]);
                $data->end_time = strtotime($interval_timer[1]);
                $data->multi_pic = (serialize(Request::instance()->param('picArr/a')));// 组图

            }
        });
    }

    // 会员优惠券记录 会员表 关联
    public function Member()
    {
        return $this->belongsTo('Member','member_id','id')->field('username,id');
    }


//    public function getCreateTimeAttr($data,$value)
//    {
//       //return date('Y-m-d',$value['create_time']);
//    }
}